home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / yardfeet.doc < prev    next >
Text File  |  1995-03-31  |  4KB  |  111 lines

  1. (Comp.sys.handhelds) 
  2. Item: 3432 by _joehorn at hpcvbbs.UUCP 
  3. Author: [Joseph K. Horn] 
  4.   Subj: HP 48 Yards.FeetInches 
  5.   Date: Tue Jun 11 1991 
  6.  
  7. Any mathematicians out there?  I need your help. 
  8.  
  9. All the code I've seen written to handle Feet.Inches pulls the number 
  10. apart into its int and frac parts, handles them, and then recombines. 
  11.  
  12. But some years ago, this algorithm for Hours.MinSec was published: 
  13.  
  14.               +-----------------------------------------+ 
  15.               | HMS->(x) = x + FP(x)/1.5 + FP(x*100)/90 | 
  16.               +-----------------------------------------+ 
  17.  
  18. The fact that it works mystifies me.  My question is: If this kind of 
  19. algorithm works for H.MS, can similar ones be created for any arbitrary 
  20. fractional systems, like Yards.FeetInches?  If so, how? 
  21.  
  22. It would sure shrink and speed up a lot of programs. 
  23.  
  24. Thanx. 
  25.  
  26. BTW, just in case it helps or amuses, here's the inverse function: 
  27.  
  28.               +-----------------------------------------+ 
  29.               | ->HMS(x) = x - .4*FP(x) - .004*FP(x*60) | 
  30.               +-----------------------------------------+ 
  31.  
  32. -- Joe Horn -- 
  33.  
  34. ---------- 
  35.   Resp: 1 of 2 by bson at rice-chex.ai.mit.edu 
  36. Author: [Jan Brittenson] 
  37.   Date: Thu Jun 13 1991 
  38.  
  39. How about: 
  40.  
  41.         YFI->(x) = x + FP(x) * 7/3 + FP(x*10) * 22/9 
  42.  
  43. Where YFI is: 
  44.  
  45.         y.fii 
  46.  
  47. I.e. 1 yard, 2 feet, 5 inches = 1.205 
  48.  
  49.    So, how does it work? Pretty simple actually. The first term maps 
  50. the integer part 1:1 (no conversion necessary). But it also maps the 
  51. .f and ..ii parts 1:1, so they need some adjustment. Feet map 1:0.3, so 
  52. as far as feet are concerned we fulfill the following equation to get 
  53. the feet back in line: 
  54.  
  55.         1 = 0.3 + 0.3 * k ==> k = (1-0.3)/0.3 = 7/3 
  56.  
  57. So we now have: 
  58.  
  59.         YFI->(x) = x + FP(x) * 7/3 
  60.  
  61.    Note that we use FP() since we have already taken care of the 
  62. integer part (which mapped 1:1). This also maps the ..ii part, so 
  63. again we need to adjust it - we would like it to map 1:0.036 (i.e. 3 * 
  64. 12in = 1ft): 
  65.  
  66.         1 = 0.036 + 0.036 * k + 0.36 * m 
  67.  
  68.         ==> m = (1-0.036-0.036*7/3)/0.36 = 22/9 
  69.  
  70. So now we have our final term. 
  71.  
  72.         YFI->(x) = x + FP(x) * 7/3 + FP(x*10) * 22/9 
  73.  
  74.    We multiply by ten and discard the IP to get rid of what is already 
  75. mapped. Apologies if this sounds confusing. 
  76.  
  77.  
  78.                                                 -- Jan Brittenson 
  79.                                                    bson@ai.mit.edu 
  80.  
  81. ---------- 
  82.   Resp: 2 of 2 by woodhams at phoenix.Princeton.EDU 
  83. Author: [Michael Woodhams] 
  84.   Date: Thu Jun 13 1991 
  85.  
  86. HMS->(H.MMSS) = H.MMSS + 0.MMSS/1.5 + 0.SS/90 
  87.               = H + MM/100 + SS/10000 + MM/150 + SS/15000 + SS/9000 
  88.               = H + MM(1/100+1/150) + SS(1/10000+1/15000+1/9000) 
  89.               = H + MM/60 + SS/3600 as required. 
  90.  
  91. Let YFI->(Y.FII) convert yards.feet_inches to decimal yards, and 
  92. assume it is of the form 
  93.  
  94. YFI->(x) = x + FP(x)/a + FP(x*10)/b 
  95.  
  96. and solve for a and b: 
  97.  
  98. YFI->(Y.FII) = Y.FII + 0.FII/a + 0.II/b 
  99.              = Y + F/10 + II/1000 + F/(10*a) + II/(1000*a) + II/(100*b) 
  100.              = Y + F*(a+1)/(10*a) + II*(a*b+b+10*a)/(1000*a*b) 
  101.              = Y + F/3 + II/36 
  102. so (a+1)/(10*a) = 1/3     =>   a=3/7 
  103. 1/36 = (a*b+b+10*a)/(1000*a*b) 
  104.      = (3*b/7+b+30/7)/(3000*b/7) 
  105.      = (3*b+7*b+30)/(3000*b) 
  106.      = (b+3)/(300*b) => b=9/22 
  107. so  
  108. YFI->(x) = x + FP(x)*7/3 + FP(x*10)*22/9 
  109.  
  110. The reverse transformation is left as an exercise for the student. 
  111.